﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Srvtools
{
    public partial class ResourceManagerEditorLanguageSelect : Form
    {
        private SYS_LANGUAGE language;

        public ResourceManagerEditorLanguageSelect(bool[] langHasSel)
        {
            InitializeComponent();

            //AddLanguages(); 注-- 如不能使用sysmessage,则使用此方法
            //language = CliSysMegLag.GetClientLanguage();
            language = CliUtils.fClientLang;
            String message = SysMsg.GetSystemMessage(language, "Srvtools", "MultiLanguage", "languages");
            string[] langs = message.Split(';');
            this.chkLstLanguage.Items.AddRange(langs);
 
            if (langHasSel[0])
                this.chkLstLanguage.SetItemChecked(0, true);
            if (langHasSel[1])
                this.chkLstLanguage.SetItemChecked(1, true);
            if (langHasSel[2])
                this.chkLstLanguage.SetItemChecked(2, true);
            if (langHasSel[3])
                this.chkLstLanguage.SetItemChecked(3, true);
            if (langHasSel[4])
                this.chkLstLanguage.SetItemChecked(4, true);
            if (langHasSel[5])
                this.chkLstLanguage.SetItemChecked(5, true);
            if (langHasSel[6])
                this.chkLstLanguage.SetItemChecked(6, true);
            if (langHasSel[7])
                this.chkLstLanguage.SetItemChecked(7, true);
        }

        public bool[] SetSelectedLang()
        { 
            bool[] bLangeSelected = new bool[8];

            if (this.chkLstLanguage.CheckedItems.Contains(this.chkLstLanguage.Items[0]))
                bLangeSelected[0] = true;
            else
                bLangeSelected[0] = false;

            if (this.chkLstLanguage.CheckedItems.Contains(this.chkLstLanguage.Items[1]))
                bLangeSelected[1] = true;
            else
                bLangeSelected[1] = false;

            if (this.chkLstLanguage.CheckedItems.Contains(this.chkLstLanguage.Items[2]))
                bLangeSelected[2] = true;
            else
                bLangeSelected[2] = false;

            if (this.chkLstLanguage.CheckedItems.Contains(this.chkLstLanguage.Items[3]))
                bLangeSelected[3] = true;
            else
                bLangeSelected[3] = false;

            if (this.chkLstLanguage.CheckedItems.Contains(this.chkLstLanguage.Items[4]))
                bLangeSelected[4] = true;
            else
                bLangeSelected[4] = false;

            if (this.chkLstLanguage.CheckedItems.Contains(this.chkLstLanguage.Items[5]))
                bLangeSelected[5] = true;
            else
                bLangeSelected[5] = false;

            if (this.chkLstLanguage.CheckedItems.Contains(this.chkLstLanguage.Items[6]))
                bLangeSelected[6] = true;
            else
                bLangeSelected[6] = false;

            if (this.chkLstLanguage.CheckedItems.Contains(this.chkLstLanguage.Items[7]))
                bLangeSelected[7] = true;
            else
                bLangeSelected[7] = false;

            return bLangeSelected;
        }

        private void AddLanguages()
        {
            //language = CliSysMegLag.GetClientLanguage();
            language = CliUtils.fClientLang;
            string[] langs;
            switch (language)
            { 
                case SYS_LANGUAGE.ENG:
                case SYS_LANGUAGE.JPN:
                case SYS_LANGUAGE.LAN3:
                case SYS_LANGUAGE.LAN1:
                case SYS_LANGUAGE.LAN2:
                    langs = new string[] { "English", "ChineseTra", "ChineseSim", "ChineseHK", "Japanese", "Korean", "OtherLanguage1", "OtherLanguage2" };
                    this.chkLstLanguage.Items.AddRange(langs);
                    break;
                case SYS_LANGUAGE.TRA:
                case SYS_LANGUAGE.HKG:
                    langs = new string[] { "英文", "中文繁體", "中文簡體", "中文香港", "日文", "韓文", "其他語言1", "其他語言2" };
                    this.chkLstLanguage.Items.AddRange(langs);
                    break;
                case SYS_LANGUAGE.SIM:
                    langs = new string[] { "英文", "中文繁体", "中文简体", "中文香港", "日文", "韩文", "其他语言1", "其他语言2" };
                    this.chkLstLanguage.Items.AddRange(langs);
                    break;
            }
        }

        private void ResourceManagerEditorLanguageSelect_Load(object sender, EventArgs e)
        {
        }
    }
}